package com.itheima.admin.controller;

import com.itheima.PageVo;
import com.itheima.Result;
import com.itheima.admin.dto.DeptDto;
import com.itheima.admin.dto.moduleDto;
import com.itheima.admin.dto.PageDto;
import com.itheima.admin.service.IModuleService;
import com.itheima.admin.vo.DeptVo;
import com.itheima.admin.vo.ModuleAllItemVo;
import com.itheima.admin.vo.RoleVo;
import com.itheima.admin.vo.moduleVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/module")
public class ModuleController {
    @Autowired
    private IModuleService moduleService;

    @PostMapping("/list")
    @ApiOperation("分页查询模块")
    public PageVo<moduleVo> queryByPage(@RequestBody PageDto pageDto){
        return moduleService.queryByPage(pageDto);
    }



    @PostMapping("/add")
    @ApiOperation("添加模块")
    public Result addmodule(@RequestBody moduleDto moduleDto){
        return moduleService.addmodule(moduleDto);
    }

    @PutMapping("/update")
    @ApiOperation("编辑模块")
    public Result updatemodule(@RequestBody moduleDto moduleDto){
        return moduleService.updatemodule(moduleDto);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除模块")
    public Result deletemodule(@PathVariable("id") String id){
        return moduleService.deletemodule(id);
    }
    @GetMapping("/{id}")
    @ApiOperation("根据ID查询模块")
    public moduleVo queryById(@PathVariable("id") String id){
        return moduleService.queryById( id);
    }

    @GetMapping("/listall")
    public List<ModuleAllItemVo> listAllModule(){
        return moduleService.listAllModule();
    }

}
